'use strict';

const _ = require('lodash');
const path = require('path');
const os = require('os');
let config = require('./config_default');

// 开发人员可配置的环境
try {
    let envConfig = {};
    if (process.env.NODE_ENV === 'dev') {
        envConfig = require('./config_local');
        config = _.merge(config, envConfig);
        console.log(config);
    } else {
        envConfig = require(path.resolve(os.homedir(),'./config/koa.config.js'));
        config = _.merge(config, envConfig);
    }
} catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') {
        log.error('[ERROR] loading config/config.js failed:', e.message); // eslint-disable-line
    }
}

module.exports = config;
